package chapter04

/**
 * @author: 余辉
 * @blog: https://blog.csdn.net/silentwolfyh
 * descriptions:
 * date: 2024 - 09 - 02 11:04 上午
 */
class MapRdd(val f: Iterator[String] => Iterator[String], var dep: List[Rdd]) extends Rdd {

  def compute(): Iterator[String] = {
    f(dep(0).iter)
  }

  def map(f: String => String): MapRdd = {
    new MapRdd(iter => iter.map(f), List(this))
  }

  override val iter: Iterator[String] = compute()

  override def foreach(f: String => Unit): Unit = iter.foreach(f)
}